#cm-dropdown-portal {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
}

.cm-dropdown {
    line-height: initial;
    position: absolute;
    padding: 0;
    opacity: 0;
    z-index: -999;
    display: none;
    pointer-events: none;
    border-radius: var(--cui-border-radius-small);
    transition: opacity 0.2s linear, z-index 0.2s linear, transform 0.1s linear;
    box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.1);
    will-change: opacity, z-index, transform;

    >.cm-dropdown-list {
        position: relative;
    }

    &.cm-dropdown-open {
        opacity: 1;
        pointer-events: all;
        z-index: 1500;
        transform: scaleY(1);
    }
}

.cm-dropdown-visible {
    display: inline-block;
    transform-origin: 0% 0%;
    transform: scaleY(0.8);
}

.cm-dropdown-rel {
    display: inline-flex;
}

.cm-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    background-color: var(--cui-dropdown-background-color, var(--cui-color-bg-3));
    min-width: 130px;
    border-radius: var(--cui-border-radius-small);

    .cm-dropdown-list {
        position: absolute;
        left: 100%;
        top: 0;
        box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.1);
        z-index: -1;
        opacity: 0;
        margin-left: 0px;
        pointer-events: none;
        transition: all 0.2s linear;
    }

    .cm-divider {
        margin: 1px 0;
    }
}

.cm-dropdown-item-open {
    >.cm-dropdown-list {
        z-index: 1;
        opacity: 1;
    }
}

.cm-dropdown-item {
    position: relative;
    list-style: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 7px 16px;
    clear: both;
    color: var(--cui-dropdown-text-color, var(--cui-color-text-0));
    font-size: 14px;
    white-space: nowrap;
    gap: 10px;
    cursor: pointer;
    transition: background .2s ease-in-out;

    &.cm-dropdown-item-selected,
    &:hover {
        background-color: var(--cui-color-fill-0);

        >.cm-dropdown-list {
            z-index: 1;
            opacity: 1;
            pointer-events: all;
        }
    }
}

.cm-dropdown-item-icon {
    display: inline-flex;
}

.cm-dropdown-item-with-arrow {
    padding-right: 32px;
}

.cm-dropdown-item-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.cm-dropdown-item-divided {
    margin-top: 10px;

    &::before {
        content: ' ';
        height: 1px;
        display: block;
        margin: 0 -16px;
        box-shadow: 0 0.2px 0 0 rgba(var(--cui-grey-1));
        position: absolute;
        width: 100%;
        top: -5px;
    }
}

.cm-dropdown[x-placement=bottom] {
    transform: translate(-50%, 0);
}

.cm-dropdown[x-placement=bottomLeft] {}

.cm-dropdown[x-placement=bottomRight] {
    transform: translate(-100%, 0);
}

.cm-dropdown[x-placement=top] {
    transform: translate(-50%, -100%);
}

.cm-dropdown[x-placement=topLeft] {
    transform: translate(0, -100%);
}

.cm-dropdown[x-placement=topRight] {
    transform: translate(-100%, -100%);
}

.cm-dropdown[x-placement=left] {
    transform: translate(-100%, -50%);
}

.cm-dropdown[x-placement=right] {
    transform: translate(0, -50%);
}

.cm-dropdown[x-placement=rightTop] {
    transform: translate(0, 0);
}

.cm-dropdown[x-placement=rightBottom] {
    transform: translate(0, -100%);
}

.cm-dropdown[x-placement=leftTop] {
    transform: translate(-100%, 0);
}

.cm-dropdown[x-placement=leftBottom] {
    transform: translate(-100%, -100%);
}

.cm-dropdown[x-placement^=top] {
    margin-top: calc(-8px - var(--cui-dropdown-offset));
}

.cm-dropdown[x-placement^=bottom] {
    margin-top: calc(8px + var(--cui-dropdown-offset));
}

.cm-dropdown[x-placement^=right] {
    margin-left: calc(8px + var(--cui-dropdown-offset));
}

.cm-dropdown[x-placement^=left] {
    margin-left: calc(-8px - var(--cui-dropdown-offset));
}

.cm-dropdown-light {
    .cm-dropdown-list {
        background-color: #fff;
    }
}

.cm-dropdown-dark {
    .cm-dropdown-list {
        background-color: rgb(var(--cui-grey-8));
    }

    .cm-dropdown-item {
        color: #efefef;

        &:hover {
            background-color: rgba(var(--cui-grey-5), 0.5);
        }
    }

    .cm-dropdown-item-disabled {
        background-color: rgb(var(--cui-grey-6));
        color: #999;
    }

    .cm-dropdown-item-divided {
        &::before {
            border-top-color: rgba(var(--cui-grey-6));
            background-color: rgba(var(--cui-grey-9), 1);
        }
    }
}

@themes: primary, success, warning, error, info, blue, green, red, yellow, magenta, pink, volcano, orange, gold, lime, cyan, geekblue, purple;

each(@themes, {
        .cm-dropdown-@{value} {
            .cm-dropdown-list {
                background-color: var(~"--cui-theme-color-@{value}");
            }

            .cm-dropdown-item {
                color: #fff;
            }

            .cm-dropdown-arrow {
                fill: var(~"--cui-theme-color-@{value}");
            }
        }
    }

);

@itemthemes: primary, secondary, tertiary, success, warning, error, info, light;

each(@itemthemes, {
        .cm-dropdown-item-@{value} {
            color: var(~"--cui-theme-color-@{value}");
        }
    }

);

.cm-dropdown-item-disabled {
    color: var(--cui-color-disabled-text);
    // background-color: var(--cui-disabled-bg-border);
    cursor: not-allowed;
    pointer-events: none;
}

.cm-dropdown-arrow {
    position: absolute;
    width: 8px;
    height: 24px;
    left: -6px;
    top: 50%;
    z-index: -1;
    -webkit-transform: translateY(-50%) rotate(180deg);
    transform: translateY(-50%) rotate(180deg);
    fill: var(--cui-dropdown-background-color, #fff);

    path:first-child {
        fill: rgba(28, 31, 35, 0.08);
    }
}

.cm-dropdown-with-arrow[x-placement^=left] {
    .cm-dropdown-arrow {
        left: auto;
        right: -6px;
        -webkit-transform: translateY(-50%);
        transform: translateY(-50%);
    }
}

.cm-dropdown-with-arrow[x-placement$=Top] {
    .cm-dropdown-arrow {
        top: 18px;
    }
}

.cm-dropdown-with-arrow[x-placement^=top] {
    .cm-dropdown-arrow {
        top: auto;
        left: 50%;
        bottom: -14px;
        transform-origin: center center;
        -webkit-transform: translateX(-50%) rotate(90deg);
        transform: translateX(-50%) rotate(90deg);
    }
}

.cm-dropdown-with-arrow[x-placement$=Bottom] {
    .cm-dropdown-arrow {
        top: calc(100% - 18px);
    }
}

.cm-dropdown-with-arrow[x-placement^=bottom] {
    .cm-dropdown-arrow {
        top: -14px;
        left: 50%;
        transform-origin: center center;
        -webkit-transform: translateX(-50%) rotate(-90deg);
        transform: translateX(-50%) rotate(-90deg);
    }
}

.cm-dropdown-with-arrow[x-placement$=Left] {
    .cm-dropdown-arrow {
        left: 18px;
    }
}

.cm-dropdown-with-arrow[x-placement$=Right] {
    .cm-dropdown-arrow {
        left: calc(100% - 18px);
    }
}